<?php

class myUser extends sfBasicSecurityUser
{
    public function isAuthenticated()
    {
        if (parent::isAuthenticated())
        {
            $cred = $this->getAttribute('credentials', array());
            if (in_array('admin', $cred))
                return true;
        }
        return false;
    }

    public function login($login, $password)
    {
       $user = Doctrine::getTable('FurryUser')->login($login, $password);
       if ($user)
       {
           $creds = $user->getCredentials();
           $creds = json_decode($creds);
           if (in_array('admin', $creds) && $user->getActive())
           {
                $this->setAuthenticated(true);
                $this->setAttribute('credentials', $creds);
                $this->setAttribute('user', $user);
           }
           else
           {
               $this->setAuthenticated(false);
           }
       }
       else
       {
           $this->setAuthenticated(false);
       }
    }
}
